package com.yulongtian.oneProblemEveryDay.month202211.day20221111;

/**
 * https://leetcode.cn/problems/determine-if-string-halves-are-alike/
 * 可
 *
 *
 * @author yulongTian
 * @create 2022-11-11 15:52
 */
public class Test01 {
    public static void main(String[] args) {
        halvesAreAlike("abcd");
    }


    public static boolean halvesAreAlike(String s) {
        int pre_num = 0;
        int latter_num = 0;

        int len = s.length();

        String preStr = s.substring(0, len / 2);
        String latterStr = s.substring(len / 2);

        for (int i = 0; i < len / 2; i++) {
            if (isYuanYin(preStr.charAt(i))) {
                pre_num++;
            }
        }
        for (int i = 0; i < len / 2; i++) {
            if (isYuanYin(latterStr.charAt(i))) {
                latter_num++;
            }
        }


        return pre_num == latter_num;
    }

    public static boolean isYuanYin(char c) {
        //大小写
        if (c >= 'a' && c <= 'z') {
            return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
        } else {
            return c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U';
        }
    }

}
